<template>
  <div :id="id" :style="size"></div>
</template>

<script>
  import * as echarts from 'echarts'
  import option from './settings'

  export default {
    name: "index",
    props: {
      id: {
        type: String,
        default: 'bar-chart'
      },
      size: {
        type: Object,
        default: () => ({
          width: '100%',
          height: '100%'
        })
      }
    },
    mounted() {
      this.drawBarChart()
    },
    methods: {
      drawBarChart() {
        const barChart = echarts.init(document.getElementById(this.id))
        barChart.setOption(option)
        window.addEventListener('resize', () => barChart.resize(), false)
      }
    }
  }
</script>

<style scoped lang="scss">

</style>
